import asyncio

async def func1():
    print('func1', 1)
    # 模拟 2s 的IO操作
    await asyncio.sleep(2)
    print('func1', 2)

async def func2():
    print('func2', 3)
    # 模拟 2s 的IO操作
    await asyncio.sleep(2)
    print('func2', 4)

async def main():
    pass
    # await asyncio.create_task(func1())
    # await asyncio.create_task(func2())

    # 创建任务时便开始执行
    # task1 = asyncio.create_task(func1())
    # task2 = asyncio.create_task(func2())

    # 等待 IO 结束
    # await task1
    # await task2

#     tasks = [
#         asyncio.create_task(func1()),
#         asyncio.create_task(func2())
#     ]

    # 该运行方法不需要在函数面前加 async
    # asyncio.run(asyncio.wait(tasks))
#     该方法需要加 async
#     await asyncio.wait(tasks)
#
#
# asyncio.run(main())

tasks = [
    func1(),
    func2()
]

asyncio.run(asyncio.wait(tasks))
